
import type { RouteLocationNormalized, NavigationGuardNext } from 'vue-router'
import Nprogress from 'nprogress'
import "nprogress/nprogress.css"

export default defineNuxtPlugin(() => {
    const router = useRouter()
    router.beforeEach(async (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {

        if (process.client) {
            Nprogress.start()
        }

        next()
    })

    router.afterEach(() => {
        if (process.client) {
            Nprogress.done()
            setTimeout(() => {
                const content = document.querySelector('.content')
                if (content) {
                    content.classList.add('animated', 'fadeIn')
                }
            }, 2000)
        }
    })
})
